package com.projetoptymo;

import com.google.android.maps.GeoPoint;

import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;

public class CurrentPosition extends Activity
{
	Location CurrentLocation;
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.main);
	    //---utilisation  de la class LocationManager pour le gps--- 
	    LocationManager objgps = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
	    //*************ecouteur ou listener*********************
	    Myobjlistener objlistener = new Myobjlistener(); 
	
	    objgps.requestLocationUpdates( 
	        LocationManager.GPS_PROVIDER, 
	        0, 
	        0, 
	        objlistener);	    
	}
	
	public GeoPoint getPosition()
	{
		return new GeoPoint((int) CurrentLocation.getLatitude()*1000000, (int) CurrentLocation.getLongitude()*1000000);
	}
	
    private class Myobjlistener implements LocationListener 
    { 
 
 
 
        public void onProviderDisabled(String provider) { 
            // TODO Auto-generated method stub 
        } 
 
 
        public void onProviderEnabled(String provider) { 
            // TODO Auto-generated method stub 
        } 
 
 
        public void onStatusChanged(String provider, int status, 
            Bundle extras) { 
            // TODO Auto-generated method stub 
        } 
 
 
          public void onLocationChanged(Location location) { 
 
        	  	CurrentLocation = location;
          } 
 
    }
 
}
